home *** CD-ROM | disk | FTP | other *** search
/ Georgia Wildfire Prevention / Georgia Wildfire Prevention.iso / pc / media / dirs / BackUp / Login.dir / 00008_Script_TextField Behavior < prev    next >
Text File  |  2002-10-11  |  3KB  |  91 lines

  1. --TEXT FIELD BEHAVIOR--
  2. --This behavior causes the text to be entered into the field and also sends information to the border
  3. --so it can "light up" around the field.
  4. --PROPERTIES--
  5. --FieldType: The type of field.
  6. --FieldSize: The size of the field used to determine how big the border should be.
  7. --LocX: The Horizontal location of the field. Tells the border where to appear.
  8. --LocY: The Vertical location of the field. Assists the border as above.
  9. --SpNum: The sprite number.
  10. --MyNum: The sprite's member number.
  11. --mymem: The member's member number.
  12. --GLOBAL HotField: Keeps track of which field is in use. Initialized and Killed in Zeus.
  13.  
  14. global HotField
  15. property FieldType, FieldSize, LocX, LocY, SpNum, MyNum,mymem
  16.  
  17. --Initializes everything.
  18. on new me
  19.   SpNum = me.spritenum
  20.   MyNum=sprite(SpNum).member.number
  21.   mymem=sprite(spnum).member
  22.   LocX = sprite(SpNum).locH
  23.   LocY = sprite(SpNum).locV
  24. end
  25.  
  26. --Creates the dialog box to define the parameters for the field.
  27. on getpropertydescriptionlist me
  28.   set pList= [#FieldType: [#comment: "Which field is this?", #format: #string, #range: ["First Name", "Last Name", "Address", "City", "State", "Zip Code", "Age"], #default: "First Name"],\
  29.  #FieldSize: [#Comment: "Pick the field size: ", #format: #string, #range: ["Big", "Medium", "Small"], #default: "Big"]]
  30.   return pList
  31. end
  32.  
  33. --When the mouse button is pressed, this function sends a message to the border to appear around it.
  34. on mousedown me
  35.   sendallsprites (#TurnOnBorder, FieldSize, LocX, LocY)
  36.   HotField = FieldType
  37. end
  38.  
  39. --This function causes the letter pressed to be entered into the field.
  40. on FieldFiller me, TheKey
  41.   if HotField = FieldType then
  42.     
  43.     if (TheKey).chartonum = 13 or (TheKey).chartonum = 9 or TheKey = "RETURN" then --If the user presses RETURN (ENTER key on the PC) or TAB the next field goes active.
  44.       sendallsprites (#TurnOnBorder, FieldSize, LocX, LocY)
  45.       
  46.     else if (TheKey).chartonum = 8 or TheKey = "BACKSPACE"  then --If the user presses BACKSPACE then it erases the last character.
  47.       delete member(MyMem).char[member(MyMem).text.chars.count]
  48.       
  49.     else if (TheKey).chartonum = 127 then --If the user presses the DELETE key the field empties.
  50.       member(MyMem).text = ""
  51.       
  52.     else if  (TheKey).chartonum > 31 and (TheKey).chartonum < 127 then --Only printable characters will be accepted.
  53.       put (TheKey) after member(MyMem).char[member(MyMem).text.chars.count]
  54.       
  55.     end if  
  56.   end if
  57. end
  58.  
  59. On TurnIn me
  60.   MyDataName = FieldType
  61.   MyData = member(MyMem).text
  62.   sendallsprites(#TheReply, MyDataName, MyData)
  63. end
  64.  
  65. on beginsprite me
  66.   global ctrlobj
  67.   case mymem.name of
  68.     "First Name":mymem.text=string(ctrlobj.userinfo.fname)
  69.     "Last Name":mymem.text=string(ctrlobj.userinfo.lname)
  70.     "Address":mymem.text=string(ctrlobj.userinfo.address)
  71.     "City":mymem.text=string(ctrlobj.userinfo.city)
  72.     "State":mymem.text=string(ctrlobj.userinfo.state)
  73.     "Zip Code":mymem.text=string(ctrlobj.userinfo.zip)
  74.     "Age":mymem.text=string(ctrlobj.userinfo.age)
  75.   end case
  76. end
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.